package com.zx.factory;

import com.zx.annotations.Service;
import com.zx.annotations.Transactional;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ProjectName: iocaop
 * @Package: com.zx.factory
 * @ClassName: BeanDefinitionFactory
 * @Author: 1
 * @Description: 1
 * @Date: 2021/9/16 9:01
 */
public class BeanDefinitionFactory {

    private  BeanDefinitionFactory(){}


    public  static  BeanDefinition  buildBeanDefinition(Class<?> c){
        BeanDefinition beanDefinition = new BeanDefinition();
        beanDefinition.setaClass(c);
        beanDefinition.setDeclaredFields(c.getDeclaredFields());
        beanDefinition.setClassName(c.getSimpleName());
        beanDefinition.setTransactional(c.getAnnotation(Transactional.class));
        beanDefinition.setService(c.getAnnotation(Service.class));

        beanDefinition.setAnnotations(c.getAnnotations());
        beanDefinition.setInterfaces(c.getInterfaces());

        try {
            beanDefinition.setConstructor(c.getConstructor());
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        return beanDefinition;
    }
}
